#!/bin/bash -e

execution_dir="$(git rev-parse --show-toplevel)/../stdexec"

git -C "${execution_dir}" rev-parse HEAD > commit.info
cp -r "${execution_dir}"/include/stdexec/* .
cp "${execution_dir}"/include/exec/{any_sender_of,async_scope,at_coroutine_exit,env,inline_scheduler,scope,task,sequence_senders}.hpp .

(find . -name "*.hpp" -print0 || true) | while IFS= read -r -d '' f
do
    sed -i "s#include <stdexec/#include <sdbusplus/async/stdexec/#" -- "${f}"
    sed -i "s#include <exec/#include <sdbusplus/async/stdexec/#" -- "${f}"
    sed -i 's#include "\./\([^"]*\)"#include <sdbusplus/async/stdexec/\1>#' -- "${f}"
    clang-format -i "${f}"
done
